package com.kygeng.springframework.aop;

import com.kygeng.springframework.util.ClassUtils;

/**
 * @Title: TargetSource
 * @Author: kygeng
 * @Package: com.kygeng.springframework.aop
 * @Date: 2024/8/10 15:39
 * @Description: 被代理的目标对象
 */
public class TargetSource {

    private final Object target;

    public TargetSource(Object target) {
        this.target = target;
    }

    public Class<?>[] getTargetClass() {
        Class<?> clazz = this.target.getClass();
        clazz = ClassUtils.isCglibProxyClass(clazz) ? clazz.getSuperclass() : clazz;
        return clazz.getInterfaces();
    }

    public Object getTarget() {
        return this.target;
    }
}
